﻿using System;
using System.Collections.Generic;
using System.Web;
using ErrorLog.ApiClient;

namespace FogBugzPd.Web.Utils
{
	public static class ErrorLogUtils
	{
		public static void Init()
		{
			//ErrorLogClient.Config.WebServiceUrl = EnvironmentUtils.GetConfigSettingStr("ErrorLog_WebServiceUrl");
		}

		public static void AddError(Exception ex, string originalErrorSubject, Dictionary<string, string> customDataItems = null)
		{
			if (!EnvironmentConfig.UseErrorLog)
				return;

			try
			{
				ErrorLogClient.AddErrorAsync(ex);
			}
			catch
			{
				//Need to log to Log4Net
			}
		}

		//Auto generate exceptions if only message
		public static void AddError(string errorMessage)
		{
			try
			{
				throw new Exception(errorMessage);
			}
			catch (Exception ex)
			{
				AddError(ex, "Original Error");
			}
		}
	}
}
